let app = getApp();
var applet_park_api_url = app.globalData.applet_park_api_url;
var applet_park_api_url_imgUrl = app.globalData.applet_park_api_url_imgUrl;
const {
  requestDataparams
} = require('../../utils/request.js');

Component({

  /* 开启全局样式设置 */
  options: {
    addGlobalClass: true,
  },

  /* 组件的属性列表 */
  properties: {
    name: {
      type: String,
      value: 'Index'
    }
  },

  /* 组件的初始数据 */
  data: {
    imgUrl: applet_park_api_url_imgUrl,
    bottomColor: '#FC8440',
    //浅色
    gradientColor: '#FB4A37',
    navs: [
      applet_park_api_url_imgUrl + '/banner2.png',
      applet_park_api_url_imgUrl + '/banner1.png',
    ],
    current: 'homepage',
    searchMain: '',
    index: 0,
    dynamiclist: [],
  },

  /* 组件声明周期函数 */
  lifetimes: {
    created: function () {

    },
    attached: function () {
      this.getLocation()
      this.getActivityLists()
    },
    moved: function () {

    },
    detached: function () {

    },
  },

  /* 组件的方法列表 */
  methods: {
    getLocation() {
      wx.getLocation({
        type: 'wgs84',
        success(res) {
          const latitude = res.latitude
          const longitude = res.longitude
          const speed = res.speed
          const accuracy = res.accuracy
        }
      })
    },
    goParkActivity(e) {
      var id = e.currentTarget.dataset.id;
      wx.navigateTo({
        url: '../../packageC/pages/parkActivityDetalis/parkActivityDetalis?id=' + id,
      })
    },
    changeTab() { //切换tab
      if (this.data.index == 0) { //优惠活动
        this.setData({
          index: 1
        })
      } else { //园区活动
        this.setData({
          index: 0
        })
        this.getActivityLists()
      }
    },
    getActivityLists() { //获取活动列表
      var that = this;
      requestDataparams('/api/information/queryIssueInformationList', {
        type: 4
      }, 'POST', 'json').then(response => {
        if (response.data.code == 0) {
          for (var i = 0; i < response.data.data.records.length; i++) {
            response.data.data.records[i].createTime = response.data.data.records[i].createTime.substring(0, 10);
          }
          that.setData({
            dynamiclist: response.data.data.records
          })

        } else {
          wx.showToast({
            title: '失败',
            icon: 'none'
          })
        }
      })
    },
    module() {
      // wx.showToast({
      //   title: '开发中，敬请期待',
      //   icon: 'none',
      //   duration: 2000
      // })
      wx.navigateTo({
        url: '../modulepagre/modulepagre',
      })
    },
    goStopCar() { //停车缴费
      // wx.showToast({
      //   title: '功能暂未开放',
      //   icon:'none'
      // })
      // return
      wx.navigateTo({
        url: '../../packageF/pages/stop_pay/stop_pay',
      })
    },
    gorestaurant() { //餐厅
      wx.navigateTo({
        // url: '../restaurantHomepage/restaurantHomepage',
        url: '../../pages/choiceRestaurant/choiceRestaurant',
      })
    },
    victormanger() {
      // wx.showToast({
      //   title: '功能暂未开放',
      //   icon:'none'
      // })
      // return
      wx.navigateTo({
        url: '../../packageA/pages/visitorIndex/visitorIndex',
      })
    },
    toMaintenance() { //报修
      // wx.showToast({
      //   title: '功能暂未开放',
      //   icon:'none'
      // })
      // return
      var id = app.globalData.id || wx.getStorageSync("id");
      if (!id) {
        wx.showToast({
          title: '无权限',
        })
        return false;

      }
      // pages / maintenanceDetail / maintenanceDetail
      wx.navigateTo({
        url: '../maintenanceList/maintenancelist',
      })
    },
    meetinging() { //会议
      // wx.showToast({
      //   title: '功能暂未开放',
      //   icon:'none'
      // })
      // return
      wx.navigateTo({
        url: '../../packageA/pages/MeetingLIat/MeetingLIat',
      })
    },
    enterParkActivity() { //园区活动
      // wx.showToast({
      //   title: '功能暂未开放',
      //   icon:'none'
      // })
      // return
      wx.navigateTo({
        url: '../../packageC/pages/parkActivity/parkActivity',
      })
    },
    enterParkrental() { //园区租赁
      // wx.showToast({
      //   title: '功能暂未开放',
      //   icon:'none'
      // })
      // return
      wx.navigateTo({
        url: '../../packageF/pages/parkrental/parkrental',
      })
    },
    enterParkService() { //更多
      // wx.showToast({
      //   title: '功能暂未开放',
      //   icon:'none'
      // })
      // return
      let id = app.globalData.id || wx.getStorageSync("id");
      if (!id) {
        wx.showToast({
          title: '游客暂无权限',
          icon: 'none'
        })
        return
      }
      wx.navigateTo({
        url: '../parkService/parkService',
      })
    },
    intro() {
      // wx.showToast({
      //   title: '暂无介绍,开发中',
      //   icon: 'success',
      //   duration: 2000
      // })
      wx.navigateTo({
        url: '../parkntroduce/parkntroduce',
      })
    },
    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */

    onShareAppMessage: function () {

    },
    NavigationInspection() { //园区服务
      // wx.showToast({
      //   title: '功能暂未开放',
      //   icon:'none'
      // })
      // return
      var that = this;
      var id = app.globalData.id || wx.getStorageSync("id");
      if (!id) {
        wx.reLaunch({
          url: '../../pages/loginidentityList/loginidentityList',
        })
        return false
      }
      wx.navigateTo({
        url: '../choiceRestaurant/choiceRestaurant',
      })
    },

  }

})